{% extends "parent.html" %}
{% block body %}
<table class="layui-hide" id="test" lay-filter="test"></table>
{% endblock %}

{% block scriptFooter %}
<script type="text/html" id="toolbarDemo">
  <div class="layui-btn-container">
    <button class="layui-btn layui-btn-sm" lay-event="doTask">一件做任务</button>
    <button class="layui-btn layui-btn-sm" lay-event="handerImgs">处理图片</button>
  </div>
</script>
<script>
  layui.use('table', function () {
    var table = layui.table;
    table.render({
      elem: '#test',
      url: '/makeTaskData',
      toolbar: '#toolbarDemo',
      title: '用户数据表',
      totalRow: true,
      cols: [[
        { type: 'checkbox', fixed: 'left' },
        { field: 'id', title: 'ID', width: 120, fixed: 'left', unresize: true, sort: true, totalRowText: '合计' },
        { field: 'task_id', title: '任务ID', width: 100, },
        { field: 'uid', title: '用户ID' },
        { field: 'price', title: '价格' },
        { field: 'task_name', title: '任务名' },
        { field: 'video_url', title: '视频连接', width: 300, },
        { field: 'media_name', title: '视频名字' },
        { field: 'level_name', title: '级别' },
        { field: 'end_time', title: '结束时间' },
      ]]
    });
    //工具栏事件
    table.on('toolbar(test)', function (obj) {
      var checkStatus = table.checkStatus(obj.config.id);
      if (obj.event === "doTask") {
        $.ajax({
          url: "/doTask",
          type: 'POST',
          data: JSON.stringify(checkStatus),
          dataType: 'json',
          contentType: 'application/json',
          success: function (data, status, xhr) {
          },
          error: function (xhr, error, exception) {
          }
        });
      } else if (obj.event === "handerImgs") {
        $.ajax({
          url: "/handerImages",
          type: 'POST',
          data: JSON.stringify(checkStatus),
          dataType: 'json',
          contentType: 'application/json',
          success: function (data, status, xhr) {
          },
          error: function (xhr, error, exception) {
          }
        });
      }
    });
  });
</script>
{% endblock %}